package com.ywu.application.standard.role.api;

import com.ywu.common.result.CommonResult;
import com.ywu.application.standard.role.dto.UserRoleAuthDto;
import com.ywu.application.standard.role.service.UserRoleAuthService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @ClassName UserRoleAuthApi
 * @Description TODO
 * @Author GroundDemo
 * @Date 2024/3/9 20:21
 * @Version 1.0
 **/
@RestController
@RequestMapping("/ywu/role/auth")
public class UserRoleAuthApi {
    @Autowired
    private UserRoleAuthService userRoleAuthService;

    /**
    * @Author GroundDemo
    * @Description 查询用户关联的角色
    * @Date 20:23 2024/3/9
    * @Param [userRoleAuthDto]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/user.role.info")
    public CommonResult<Object> queryUserRoleInfo(@RequestBody UserRoleAuthDto userRoleAuthDto) {
        return userRoleAuthService.queryUserRoleInfo(userRoleAuthDto);
    }

    /**
    * @Author GroundDemo
    * @Description 用户角色授权管理
    * @Date 20:52 2024/3/9
    * @Param [userRoleAuthDtos]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/user.role.auth.create.info")
    public CommonResult<Object> userRoleAuthCreateInfo(@RequestBody List<UserRoleAuthDto> userRoleAuthDtos) {
        return userRoleAuthService.userRoleAuthCreateInfo(userRoleAuthDtos);
    }

    /**
    * @Author GroundDemo
    * @Description 删除用户时删除授权信息
    * @Date 19:19 2025/3/26
    * @Param [userRoleAuthDtos]
    * @return com.ywu.common.result.CommonResult<java.lang.Object>
    **/
    @PostMapping("/user.role.auth.delete.info")
    public CommonResult<Object> userRoleAuthDeleteInfo(@RequestBody List<UserRoleAuthDto> userRoleAuthDtos) {
        return userRoleAuthService.userRoleAuthDeleteInfo(userRoleAuthDtos);
    }
}
